package edu.hawaii.duedates.libraries;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Formatter;
import java.util.Locale;

/**
 * Class for books.
 * 
 * @author Ka Hung Phillip Lau
 * @author Creighton Okada
 *
 */
public final class LibraryBook {
  private final String bookTitle;
  private final Date bookDueDate;
  
  /**
   * Book constructor.
   * @param title the book's title
   * @param dueDate the book's due date
   */
  protected LibraryBook(String title, Date dueDate) {
    this.bookTitle = title;
    this.bookDueDate = dueDate;
  }
  /**
   * Returns book's due date.
   * @return book's due date
   */
  protected Date getBookDueDate() {
    return bookDueDate;
  }
  /**
   * Returns book's title.
   * @return book's title
   */
  protected String getBookTitle() {
    return bookTitle;
  }
  /**
   * Overriding toString method.
   * @return book information in a formatted string
   */
  public String toString() {
    DateFormat newFormat = new SimpleDateFormat("MM/dd/yyyy", Locale.US);
    StringBuilder outputString = new StringBuilder();
    Formatter formatter = new Formatter(outputString);

    String format = "|%-70.70s\t|%-10s|\n";
    formatter.format(format, bookTitle, newFormat.format(bookDueDate));
    return outputString.toString();
  }
}
